<template>
    <div>
        <el-button @click="adduser">
            添加
        </el-button>
        <vxe-table border="none" class="page-vxe-table" ref="cusTableRef" size="small" align="left"
            :sort-config="{ multiple: false, remote: true }"
            :loading-config="{ icon: 'vxe-icon-indicator roll', text: ' ' }" :expand-config="{
            accordion: true,
            visibleMethod: () => false,
            showIcon: false,
        }" show-overflow :row-config="{ isHover: true, height: 50 }" :loading="table.loading" :data="table.data">
            <vxe-column type="checkbox" width="60"></vxe-column>
            <vxe-column field="name" align="left" title="名称"> </vxe-column>
            <vxe-column field="source_from" align="left" title="来源">
                <template #default="{ row }">
                    <span v-if="row.source_from === 1">系统</span>
                    <span v-else>自主</span>
                </template>
            </vxe-column>
            <vxe-column field="group_name" title="分组"> </vxe-column>
            <vxe-column field="agent_name" title="代理"> </vxe-column>
            <vxe-column field="channel_name" title="渠道"> </vxe-column>
            <vxe-column field="remain_service_at" width="120" title="剩余时长">

            </vxe-column>
            <vxe-column field="share_times" title="分享次数"> </vxe-column>

            <vxe-column field="last_login_at" width="160" sortable title="最近登录时间">

            </vxe-column>

            <vxe-column field="last_login_ip" width="110" title="最近登录ip">
                <template #default="{ row }">
                    {{ row.last_login_ip || "-" }}
                </template>
            </vxe-column>
            <vxe-column field="last_login_region" width="120" title="最近登录归属地">
                <template #default="{ row }">
                    {{ row.last_login_region || "-" }}
                </template>
            </vxe-column>
            <vxe-column field="created_at" width="160" sortable title="注册时间">

            </vxe-column>
            <vxe-column field="status" title="状态">
                <template #default="{ row }">
                    <el-switch v-model="row.status" style="
                --el-switch-on-color: var(--theme);
                --el-switch-off-color: #f1f1f1;
              " :active-value="1" :inactive-value="-1" />
                </template>
            </vxe-column>
            <vxe-column field="" width="280" align="right" title="操作">
                <template #default="{ row }">
                    <div class="operate">

                    </div>
                </template>
            </vxe-column>
        </vxe-table>
    </div>

</template>

<script setup lang="ts">
import { reactive } from 'vue';
import { addUserData, getUserData } from "@/api/userInfo";
const table = reactive({
    loading: false,
    data: [{}]
})
getUserData({
    key: "",
    offset: 1,
    limit: 10,
    sorts: 'name asc'
}).then((res) => {
    console.log(res);
    table.data = res.data.list
})
const adduser = () => {
    addUserData({
        name: 'root',
        password: "111"
    })
}
</script>

<style lang="scss" scoped></style>
